package com.seculab.admin.service;

import java.rmi.RemoteException;
import java.util.List;

import org.apache.log4j.Logger;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
import org.springframework.beans.factory.annotation.Autowired;

import com.seculab.admin.dao.DefaultDAO;
import com.seculab.admin.domain.Code;

@RemoteProxy(name="dwrService")
public class DwrServiceImpl implements DwrService {
	private static final Logger logger = Logger.getLogger(DwrServiceImpl.class);
	
	@Autowired
	private DefaultDAO defaultDAO;
	
	@RemoteMethod
	public List getCodeList(String code_type) throws RemoteException {
		try {
			if(code_type == null || code_type.length() == 0) {
				return null;
			}
			
			Code code = new Code();
			code.setCode_type(code_type);
			
			return defaultDAO.selectList("Code.getListCode", code);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new RemoteException(e.getMessage());
		}
	}
	
	@RemoteMethod
	public String getData(String code_type) throws RemoteException {
		return code_type;
	}

}
